home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Scene Storm
/
Scene Storm - Volume 1.iso
/
coding
/
asm
/
games
/
randomnumber
/
randomnumber020.s
Wrap
Text File
|
1980-01-03
|
2KB
|
70 lines
*******************************************************************************
* GetRnd020()
* -----------
* $Inputs: d0.l = maximum random value to get..
* $Outputs: d0.l = random value within the specified range..
*
* $Notes: Random function re-written to take advantage of 020+ cpu`s &
* above. Also 100% pc-relative.
*
* $SpeedTest: Approx 50 random no.`s in 7 rasters on A1200/020 chipram
* Approx 50 random no.`s in 4 raster with fastram onboard!
*******************************************************************************
ciatodlow = $800
ciatodhi = $A00
ciatodmid = $900
_ciaa = $BFE001
section chip,code_c
ee cmp.b #99,$dff006
bne.s ee
move.w #$f0f,$dff180
move.w #50-1,d7
rands
moveq #5,d0
bsr GetRnd020
dbra d7,rands
move.w #$bbc,$dff180
btst #6,$bfe001
bne.s ee
rts
cnop 0,4
GetRnd020: lea maxrand(pc),a0
move.l d0,d2
beq.s initrand
tst.b seeded-maxrand(a0)
bne.b valid_seed
bsr.s initrand
move.l d2,d0
valid_seed: move.l d0,(a0) ;maxrand
moveq #0,d1
move.b (_ciaa+ciatodlow).l,d1
add.l random_seed(pc),d1
move.l #$19660D,d0
mulu.l d1,d1:d0
move.l d0,random_seed-maxrand(a0)
clr.w d0
swap d0
move.l (a0),d3 ;maxrand
mulu.w d3,d0
clr.w d0
swap d0
rts
cnop 0,4
initrand st.b seeded-maxrand(a0)
move.b (_ciaa+ciatodhi).l,d0
lsl.l #8,d0
move.b (_ciaa+ciatodmid).l,d0
lsl.l #8,d0
move.b (_ciaa+ciatodlow).l,d0
move.l d0,random_seed-maxrand(a0)
rts
maxrand dc.l 0
random_seed dc.l 0
seeded dc.w 0